package 线程.day2.demo3;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args)throws Exception {
        ThreadPoolExecutor pool=new ThreadPoolExecutor(
                2,
                4,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue(3),
                new ThreadPoolExecutor.DiscardOldestPolicy());

        for(int i=1;i<=20;i++){
            String data="work:"+i;
            System.out.println("put:"+data);
            pool.execute(new T(data));
            Thread.sleep(5);
        }
    }
}
